//
//  YYPopButton.swift
//  SinaWeibo
//
//  Created by Apple on 16/5/10.
//  Copyright © 2016年 devshaw. All rights reserved.
//

import UIKit

class YYPopButton: UIButton {
    override init(frame: CGRect) {
        super.init(frame: frame)

        setupUI()
    }

    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }


    private func setupUI(){
        //字体
        titleLabel?.font = UIFont.systemFontOfSize(16)
        //颜色
        setTitleColor(UIColor.darkGrayColor(), forState: UIControlState.Normal)
        //居中
        titleLabel?.textAlignment = .Center
        //填充模式
        imageView?.contentMode = .Center


    }

    override func layoutSubviews() {
        super.layoutSubviews()

        imageView?.frame.size = CGSizeMake(self.frame.width, self.frame.width)
        imageView?.frame.origin.x = 0
        imageView?.frame.origin.y = 0

        titleLabel?.frame.size = CGSizeMake(self.frame.width, self.frame.height - self.frame.width)
        titleLabel?.frame.origin.x = 0
        titleLabel?.frame.origin.y = self.frame.width
    }
}
